package com.nhim.cms.domain;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * ElementTemplate entity. @author Huy Lieu Ta
 */
@Entity
@Table(name = "nhim_template", catalog = "nhim_cms")
public class Template implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private String name;
	private Integer groupTemplateId;
	private Integer siteTemplateId;
	private Integer version;
	private Boolean isDefault;
	private Integer type;
	private ContentType contentType;
	
	// Constructors

		/** default constructor */
		public Template() {
		}

		/** minimal constructor */
		public Template(String name, Integer type) {
			this.name = name;
			this.type = type;
		}

		/** full constructor */
		public Template(String name, Integer groupTemplateId, Integer siteTemplateId,
				Integer version, Boolean isDefault,ContentType contentType,Integer type) {
			this.name = name;
			this.groupTemplateId = groupTemplateId;
			this.siteTemplateId = siteTemplateId;
			this.isDefault = isDefault;
			this.contentType = contentType;
			this.type = type;
			this.version = version;
		}
	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	@Column(name = "name", nullable = false, length = 100)
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the groupTemplateId
	 */
	@Column(name = "group_template_id")
	public Integer getGroupTemplateId() {
		return groupTemplateId;
	}
	/**
	 * @param groupTemplateId the groupTemplateId to set
	 */
	public void setGroupTemplateId(Integer groupTemplateId) {
		this.groupTemplateId = groupTemplateId;
	}
	/**
	 * @return the siteTemplateId
	 */
	@Column(name = "site_template_id")
	public Integer getSiteTemplateId() {
		return siteTemplateId;
	}
	/**
	 * @param siteTemplateId the siteTemplateId to set
	 */
	public void setSiteTemplateId(Integer siteTemplateId) {
		this.siteTemplateId = siteTemplateId;
	}
	
	/**
	 * @return the isDefault
	 */
	@Column(name = "is_default")
	public Boolean getIsDefault() {
		return isDefault;
	}
	/**
	 * @param isDefault the isDefault to set
	 */
	public void setIsDefault(Boolean isDefault) {
		this.isDefault = isDefault;
	}
	/**
	 * @return the contentType
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "content_type_id", nullable = true)
	public ContentType getContentType() {
		return contentType;
	}
	/**
	 * @param contentType the contentType to set
	 */
	public void setContentType(ContentType contentType) {
		this.contentType = contentType;
	}
	
	/**
	 * @return the version
	 */
	@Version
	@Column(name = "version")
	public Integer getVersion() {
		return version;
	}
	/**
	 * @param version the version to set
	 */
	public void setVersion(Integer version) {
		this.version = version;
	}

	/**
	 * @return the type
	 */
	@Column(name = "type")
	public Integer getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(Integer type) {
		this.type = type;
	}

}
